use talib::common::{TimePeriodKwargs, ta_initialize, ta_shutdown, TimePeriodKwargsBuilder};
use talib::overlap::{ta_ema,};


pub fn EMA(data: &Vec<f64>, period:i32)->Option<Vec<f64>> {
    let _ = ta_initialize();
    let kwargs = TimePeriodKwargsBuilder::default().timeperiod(period).build().unwrap();
    let res = ta_ema(data.as_ptr(), data.len(), &kwargs);
    let ret:Option<Vec<f64>>;
    match res {
        Ok(ema_values) => {
            ret = Some(ema_values);
        }
        Err(e) => {
            ret = None;
        }
    }
    let _ = ta_shutdown();

    ret
}

pub fn EMA2(data: &Vec<f64>, short:i32, long:i32) {
    let short_ret = EMA(data, short);
    let long_ret = EMA(data, long);



}